package com.tanhua;

import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;
import java.util.Map;

public class DemoTest4 {

    //参照文档 硬编码书写（太繁琐）
    public static void main(String[] args) {
        //创建一个http客户端 发送post请求   获取权限的方法
        RestTemplate restTemplate = new RestTemplate();

        String url = "http://a1.easemob.com/1172210114153525/demo/token";
        Map<String, String> paramMap = new HashMap<>();
        paramMap.put("grant_type","client_credentials");
        paramMap.put("client_id","YXA6fnvNvj0mTWWxSR9wD32vwA");
        paramMap.put("client_secret","YXA6iWKFDPnv_8LLPS85xaR-WfHZ2a8");
        ResponseEntity<Map> mapResponseEntity = restTemplate.postForEntity(url, paramMap, Map.class);
        Map respMap = mapResponseEntity.getBody();
        String token = (String)respMap.get("access_token");
        System.out.println(token);
    }




}
